package com.framework.loippi.entity;

import java.util.Date;

import org.jsoup.Jsoup;
import org.springframework.format.annotation.DateTimeFormat;

import com.framework.loippi.mybatis.eitity.GenericEntity;
import com.framework.loippi.mybatis.ext.annotation.Column;
import com.framework.loippi.mybatis.ext.annotation.Table;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Entity - 文章
 * 
 * @author Loippi Team
 * @version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "T_JW_ARTICLE")
@ApiModel(value = "文章对象", description="文章对象")
public class Article implements GenericEntity {

	private static final long serialVersionUID = 4708111795696268541L;


	/** ID */
	@ApiModelProperty(value = "ID", required = true)
	@Column(id = true, name = "ID", updatable = false)
	private Long id;

	/** 创建时间 */
	@ApiModelProperty(value = "创建时间", required = true)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "CREATE_DATE")
	private Date createDate;

	/** 标题 */
	@ApiModelProperty(value = "标题 ", required = true)
	@Column(name = "TITLE")
	private String title;

	/** 内容 */
	@ApiModelProperty(value = "内容", required = true)
	@Column(name = "CONTENT")
	private String content;

	/** 图片 */
	@ApiModelProperty(value = "图片", required = true)
	@Column(name = "IMAGE")
	private String image;

	/** 分类 */
	@ApiModelProperty(value = "分类 ID", required = true)
	@Column(name = "ARTICLE_CATEGORY_ID")
	private Long categoryId;

	/** 创建者 */
	@ApiModelProperty(value = "创建者", required = true)
	@Column(name = "CREATOR")
	private String creator;

	/** 是否显示 */
	@ApiModelProperty(value = "是否显示(1-显示)", required = true)
	@Column(name = "IS_SHOW")
	private boolean show;

	/** 创建时间 */
	@ApiModelProperty(value = "发布时间", required = true)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name = "PUBLISH_DATE")
	private Date publishDate;
	
	/**类型(1-帮助文章，2-系统文章) */
	private Integer type;

	
	// 分类
	/*private ArticleCategory category;*/

	// 获取文本内容
	public String getText() {
		if (getContent() != null) {
			return Jsoup.parse(getContent()).text();
		}
		return null;
	}

}
